

/**
 * DataTables
 */
var datatable = null,idList=[];

$(function() {
	getIssuePeriodSelectList();
	datatable = $('.table-sort').dataTable({
		order: [
			[1, 'asc']
		],
		bRetrieve: true,
		autoWidth: true,
		searching : false,
		lengthChange: false,
		processing: true, //当datatable获取数据时�?�是否显示正在处理提示信息�??
		serverSide: true, //服务器处理分�?
		responsive: {
			details: false
		},
		//lengthMenu: [100],   // 每页显示数据（默认是10�?
		ordering: false,//是否允许用户排序
		paging: true,//是否分页
		pagingType: "full_numbers",//除首页�?�上�?页�?�下�?页�?�末页四个按钮还有页数按�?
		/* scrollX: true,//允许水平滚动
		 scrollY: "200px",
		 scrollCollapse: true, */
		stateSave: false,//刷新时是否保存状�?
		//deferRender: true,//延迟渲染
		ajax: {
			url: contextPath + "/report/getSCardPageList",
			type: 'post',
			data: function(d) {
				d.issuePeriodId = $('#issuePeriodSelectList').val();
				d.splitPattern = $('#splitPattern').val();
			}
		},
		language: {
			"url": "../resources/js/datatables_language.json"
		},
		columns: [
			{data: "issueSETime",defaultContent: ""},
			{data: "scenicSpot",defaultContent: ""},
			{data: "splitPattern",defaultContent: ""},
			{data: "split",defaultContent: ""},
			{data: "count",defaultContent: ""}
		],
		columnDefs: [ {
			targets: [2],
			render: function(data, type, row, meta) {
				if (data == 1) return '比例分成';
				else if (data == 2) return '权重';
				else if (data == 3) return '免费';
			}
		}]
	});

});


function getIssuePeriodSelectList(){
	jQuery.ajax({
		type:"POST",
		dataType:"json",
		url:contextPath + "/issuePeriod/getSelectList",
		success:function(data){
			var unitObj=document.getElementById("issuePeriodSelectList");
			if(data != null){
				//alert(JSON.stringify(selectList));
				for(var i = 0; i < data.length; i++){
					//先创建好select里面的option元素
					var option = document.createElement("option");
					//转换DOM对象为JQ对象,好用JQ里面提供的方�? 给option的value赋�??
					$(option).val(data[i].value);
					//给option的text赋�??,这就是你点开下拉框能够看到的东西
					$(option).text(data[i].text);
					//获取select 下拉框对�?,并将option添加进select
					$('#issuePeriodSelectList').append(option);
				}
			}
		},
		error:function(){
			J.alert('Error loading Json document');
		}
	});
}


function selectOnchange(){
	$('.table-sort').dataTable().fnDraw(false);
}
